home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
rmtlog1a
/
frmevent.frm
(
.txt
)
< prev
next >
Wrap
Visual Basic Form
|
1999-03-21
|
7KB
|
220 lines
VERSION 5.00
Begin VB.Form frmEventLogTestFrame
BorderStyle = 1 'Fixed Single
Caption = "Event Log Test Frame"
ClientHeight = 3360
ClientLeft = 3516
ClientTop = 4368
ClientWidth = 5424
Icon = "frmEventLogTestFrame.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3360
ScaleWidth = 5424
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdLog
Caption = "&Log It!"
Height = 465
Left = 3930
TabIndex = 14
Top = 2790
Width = 1365
End
Begin VB.ComboBox cboEventType
Height = 315
ItemData = "frmEventLogTestFrame.frx":0442
Left = 1320
List = "frmEventLogTestFrame.frx":0459
Style = 2 'Dropdown List
TabIndex = 13
Top = 2910
Width = 2415
End
Begin VB.TextBox txtEventID
CausesValidation= 0 'False
Height = 315
Left = 1320
TabIndex = 11
Top = 2490
Width = 1005
End
Begin VB.TextBox txtMessage
CausesValidation= 0 'False
Height = 915
Left = 1320
MultiLine = -1 'True
TabIndex = 9
Top = 1470
Width = 3975
End
Begin VB.TextBox txtSource
CausesValidation= 0 'False
Height = 315
Left = 1320
TabIndex = 4
Top = 690
Width = 2235
End
Begin VB.TextBox txtHost
CausesValidation= 0 'False
Height = 315
Left = 1320
TabIndex = 2
Top = 300
Width = 2235
End
Begin VB.CommandButton cmdDisconnect
Caption = "&Disable!"
Height = 465
Left = 3930
TabIndex = 6
Top = 600
Width = 1365
End
Begin VB.CommandButton cmdConnect
Caption = "&Enable!"
Default = -1 'True
Height = 465
Left = 3930
TabIndex = 5
Top = 90
Width = 1365
End
Begin VB.Label lblType
BackStyle = 0 'Transparent
Caption = "Event Type:"
Height = 195
Left = 240
TabIndex = 12
Top = 2970
Width = 885
End
Begin VB.Label lblEventID
BackStyle = 0 'Transparent
Caption = "Event ID:"
Height = 195
Left = 240
TabIndex = 10
Top = 2550
Width = 885
End
Begin VB.Label lblMessage
BackStyle = 0 'Transparent
Caption = "Message:"
Height = 195
Left = 240
TabIndex = 8
Top = 1530
Width = 885
End
Begin VB.Label lblSource
BackStyle = 0 'Transparent
Caption = "Source:"
Height = 195
Left = 240
TabIndex = 3
Top = 750
Width = 885
End
Begin VB.Label lblHost
BackStyle = 0 'Transparent
Caption = "Host (UNC):"
Height = 195
Left = 240
TabIndex = 1
Top = 360
Width = 885
End
Begin VB.Label lblAddHeader
BackColor = &H8000000D&
Caption = " Add New Events"
BeginProperty Font
Name = "MS Sans Serif"
Size = 7.8
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 210
Left = 120
TabIndex = 7
Top = 1170
Width = 5175
End
Begin VB.Label lblStatus
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Not connected."
Height = 195
Left = 120
TabIndex = 0
Top = 60
Width = 1110
End
Attribute VB_Name = "frmEventLogTestFrame"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private mobjLog As RMTLogLib.EventLog
Private Sub SetEnabledStatus()
If mobjLog.Enabled Then
If mobjLog.LogDestination <> "" Then
lblStatus.Caption = "Connected to " & txtSource.Text & " at " & txtHost.Text
Else
lblStatus.Caption = "Connected to " & txtSource.Text
End If
Else
lblStatus.Caption = "Not connected."
End If
cmdConnect.Default = (mobjLog.Enabled)
cmdDisconnect.Default = (mobjLog.Enabled)
End Sub
Private Sub cmdConnect_Click()
On Error GoTo ConnectError
If txtHost.Text <> "" Then
lblStatus.Caption = "Connecting to Event Log " & txtSource.Text & " at " & txtHost.Text & "..."
Else
lblStatus.Caption = "Connecting to Event Log " & txtSource.Text & "..."
End If
mobjLog.LogDestination = txtHost.Text
mobjLog.EventSource = txtSource.Text
mobjLog.Enabled = True
cmdDisconnect.Default = True
SetEnabledStatus
Exit Sub
ConnectError:
MsgBox Err.Number & " [" & Err.Description & "]"
SetEnabledStatus
End Sub
Private Sub cmdDisconnect_Click()
mobjLog.Enabled = False
cmdConnect.Default = True
SetEnabledStatus
End Sub
Private Sub cmdLog_Click()
On Error GoTo LogError
If mobjLog.WriteLog(txtMessage.Text, cboEventType.ItemData(cboEventType.ListIndex), CLng(Val(txtEventID.Text))) Then
MsgBox "Logged your event OK!"
Else
MsgBox "Couldn't log your event!"
End If
Exit Sub
LogError:
MsgBox Err.Number & " [" & Err.Description & "]"
End Sub
Private Sub Form_Load()
'Set mobjLog = New RMTLogLib.NTEventLog
'Set mobjLog = New RMTLogLib.EventLog
Set mobjLog = New RMTLogLib.XMLEventLog
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set mobjLog = Nothing
End Sub